package com.lyy.weather.database;

import android.content.Context;
import android.util.Log;

import com.lyy.weather.bean.AirIndices;
import com.lyy.weather.bean.City;
import com.lyy.weather.bean.LifeIndices;
import com.lyy.weather.bean.WeatherDaily;
import com.lyy.weather.bean.WeatherHourly;
import com.lyy.weather.bean.WeatherTimely;
import com.lyy.weather.layout.bean.MainItem;

import java.util.List;

//关于把数据库里的数据放到控件上的工具类
public class LayoutUtil {
    private DatabaseUtil dbUtil;
    private Context mContext;
   // private DatabaHelper dbHelper;
    private String locationId;//当前城市/地区的编号

    private City city;
    private WeatherTimely weatherTimely;
    private List<WeatherHourly> weatherHourlyList;
    private List<WeatherDaily> weatherDailyList;
    private AirIndices airIndices;
    private LifeIndices lifeIndices;


    public LayoutUtil(DatabaseUtil dbUtil, String locationId) {
        this.dbUtil = dbUtil;
        this.locationId = locationId;
        city=(City)dbUtil.searchCity(locationId);
        weatherTimely=(WeatherTimely)dbUtil.searchWeatherTimely(locationId);
        weatherHourlyList=dbUtil.searchWeatherHourly(locationId);
        weatherDailyList=dbUtil.searchWeatherDaily(locationId);
        airIndices=(AirIndices)dbUtil.searchAirIndices(locationId);
        lifeIndices=(LifeIndices)dbUtil.searchWeatherTimely(locationId);
    }

    public void test(){

   }

    //把数据塞进MainItem里
    public MainItem setDataInMainItem(){

        MainItem mainItem=new MainItem();
        mainItem.setCity(city.getName());
        mainItem.setTempMaxAndMin(weatherDailyList.get(0).getTempMax()+"/"+
                weatherDailyList.get(0).getTempMin()+"℃");
        mainItem.setTemperature(weatherTimely.getTemp());
        mainItem.setAirCategory(airIndices.getCategory());

        return mainItem;
    }



}
